package p270jp.pxv.android.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import java.util.List;
import java.util.Objects;
import p014ae.View$OnClickListenerC0151s;
import p014ae.View$OnClickListenerC0158t;
import p014ae.View$OnClickListenerC0163u;
import p045be.IllustGridRecyclerAdapter;
import p045be.NovelDetailProfileGridAdapter;
import p090d0.C2518n;
import p134ei.AnalyticsAction;
import p184gi.FirebaseScreenNameVia;
import p270jp.pxv.android.R;
import p270jp.pxv.android.activity.UserProfileActivity;
import p270jp.pxv.android.legacy.model.PixivIllust;
import p270jp.pxv.android.legacy.model.PixivUser;
import p307l9.EdgeTreatment;
import p314lg.ViewWorkDetailProfileBinding;
import p451qm.GridItemDecoration;
import p677zi.PixivImageLoader;

/* renamed from: jp.pxv.android.view.DetailProfileWorksView */
/* loaded from: classes2.dex */
public class DetailProfileWorksView extends RelativeLayout {

    /* renamed from: g */
    public static final /* synthetic */ int f19495g;

    /* renamed from: b */
    public PixivUser f19497b;

    /* renamed from: c */
    public IllustGridRecyclerAdapter f19498c;

    /* renamed from: d */
    public NovelDetailProfileGridAdapter f19499d;

    /* renamed from: e */
    public FirebaseScreenNameVia f19500e;

    /* renamed from: a */
    public ViewWorkDetailProfileBinding f19496a = (ViewWorkDetailProfileBinding) DataBindingUtil.m11370c(LayoutInflater.from(getContext()), R.layout.view_work_detail_profile, this, true);

    /* renamed from: f */
    public PixivImageLoader f19501f = (PixivImageLoader) C2518n.m7641d(PixivImageLoader.class);

    public DetailProfileWorksView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f19496a.f21866w.m10871g(new GridItemDecoration(getContext().getResources().getDimensionPixelSize(R.dimen.illust_item_divider_size), 3, 0));
        this.f19496a.f21866w.setLayoutManager(new GridLayoutManager(getContext(), 3));
        this.f19496a.f21866w.setHasFixedSize(true);
        this.f19496a.f21863t.setOnClickListener(new View$OnClickListenerC0158t(this, 26));
        this.f19496a.f21865v.setOnClickListener(new View$OnClickListenerC0151s(this, 21));
        this.f19496a.f21867x.setOnClickListener(new View$OnClickListenerC0163u(this, 21));
    }

    /* renamed from: a */
    public void m4500a() {
        if (this.f19497b != null) {
            getContext().startActivity(UserProfileActivity.m4690e1(getContext(), this.f19497b.f19078id));
        }
    }

    /* renamed from: b */
    public void m4499b(PixivUser pixivUser, List<PixivIllust> list) {
        EdgeTreatment.m3909i(pixivUser);
        EdgeTreatment.m3909i(list);
        if (this.f19496a.f21866w.getAdapter() == null) {
            IllustGridRecyclerAdapter tVar = new IllustGridRecyclerAdapter(getContext(), 1, 3);
            this.f19498c = tVar;
            tVar.f4910j = this.f19500e;
            this.f19496a.f21866w.setAdapter(tVar);
        }
        this.f19497b = pixivUser;
        this.f19501f.m60f(getContext(), pixivUser.profileImageUrls.getMedium(), this.f19496a.f21863t);
        this.f19496a.f21865v.setText(pixivUser.name);
        FollowButton followButton = this.f19496a.f21862s;
        AnalyticsAction aVar = AnalyticsAction.FOLLOW_VIA_WORK;
        AnalyticsAction aVar2 = AnalyticsAction.UNFOLLOW_VIA_WORK;
        followButton.f19513b = pixivUser;
        followButton.f19514c = aVar;
        followButton.f19515d = aVar2;
        followButton.m4494b();
        if (list.size() > 0) {
            this.f19496a.f21864u.setVisibility(8);
            IllustGridRecyclerAdapter tVar2 = this.f19498c;
            List<PixivIllust> subList = list.subList(0, Math.min(3, list.size()));
            Objects.requireNonNull(tVar2);
            EdgeTreatment.m3909i(subList);
            tVar2.m10337r(subList, subList, null);
            this.f19498c.f3606a.m10780b();
        }
    }

    public void setUserUnitWorkClickAnalytics(FirebaseScreenNameVia kVar) {
        this.f19500e = kVar;
    }
}
